package com.briup.demo;


import com.briup.demo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    // 插入用户信息
    public void insertUserXML();

    // 根据主键ID查询
    @Select("select * from ess_user where id = #{id}")
    public User getUserById(int id);
    // 条件查询
    @Select("select * from ess_user where username like '%${username}%' and gender = #{gender}")
    public List<User> querySelect (@Param("username")String username, @Param("gender") char gender);

    // 新增
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into ess_user(avatar,username,password,phone,gender,status,birthday,register_time) " +
            "values(#{avatar}, #{username}, #{password}, #{phone}, #{gender}, #{status}, #{birthday}, #{registerTime})")
    public void insertUser(User user);

    // 更新
    @Update("update ess_user set username = #{username}, phone = #{phone}, gender = #{gender}, status = #{status}, birthday = #{birthday} where id = #{id}")
    public void updateUser(User user);

}
